import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { AIManager } from "../../scene/ai/AIManager";
import { AIType } from "../../scene/ai/AIType";
import { SMoney } from "../../../../Message/Game/SMoney";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Cache } from "../../cache/Cache";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { ENpcEffect } from "../../../../Message/Public/ENpcEffect";
import { FlyFootBmp } from "../mapUI/flyFoot/FlyFootBmp";
import { BgItem } from "../common/BgItem";
import { NetDispatcher } from "../../../mvc/core/NetDispatcher";
import { ServerCommand } from "../../mvc/ServerCommand";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { DisplayUtil } from "../../../common/DisplayUtil";
import { TaskTargetInfo } from "../../model/TaskTargetInfo";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
//class AttachedSoulBattlefieldExplainWindow
    
    export  class AttachedSoulBattlefieldExplainWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(421, 460);
            titleHeight = 26;
            title = Language.getString(28584);
            return;
        }

        /* internal  */onClickGotoBtnHandler(arg1): void
        {
            if (this._npcTarget) 
            {
                hide();
                AIManager.onAutoPathAIControl(this._npcTarget);
            }
            return;
        }

        /* internal  */onClickSendBtnHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._npcTarget) 
            {
                hide();
                AIManager.onAIControl(this._npcTarget, AIType.AI_Convey);
            }
            return;
        }

        /* internal  */onMoneyUpdateHandler(arg1: SMoney=null): void
        {
            this._money.htmlText = Language.getStringByParam(28632, HTMLUtil.addColor(Cache.instance.role.money.spiritCoin.toString(), GlobalStyle.color2));
            return;
        }

        /* internal  */onLoadResHandler(): void
        {
            pushUIToDisposeVec(ObjCreate.createGBitmap(ImagesConst.AttachedSoulBattlefieldExplainTitle, 18, 38, this));
            pushUIToDisposeVec(ObjCreate.createGBitmap(ImagesConst.AttachedSoulBattlefieldExplainTxt_1, 30, 198, this));
            pushUIToDisposeVec(ObjCreate.createGBitmap(ImagesConst.AttachedSoulBattlefieldExplainTxt_2, 30, 295, this));
            pushUIToDisposeVec(ObjCreate.createGBitmap(ImagesConst.AttachedSoulBattlefieldExplainTxt_3, 30, 320, this));
            pushUIToDisposeVec(ObjCreate.createBg(143, 138, 140, 22, this, ImagesConst.yellowBoxCell));
            pushUIToDisposeVec(ObjCreate.createGTextField(Language.getString(28628), 158, 140, 120, 20, this, GlobalStyle._textFormat5));
            return;
        }

        protected /* override */ createDisposedChildrenImpl(): void
        {
            var loc5=0;
            var loc6=0;
            var loc7=null;
            super.createDisposedChildrenImpl();
            this._npcTarget = Cache.instance.scene.getNpcByEffect(ENpcEffect._ENpcEffectCrossSpiritWarShop);
            pushUIToDisposeVec(ObjCreate.createBg(18, 190, 385, 220, this));
            pushUIToDisposeVec(ObjCreate.createGTextField(Language.getString(28630), 115, 293, 100, 20, this, GlobalStyle._textFormat5));
            pushUIToDisposeVec(ObjCreate.createGTextField(Language.getString(28631), 115, 318, 220, 20, this, GlobalStyle._textFormat5));
            var loc1=ObjCreate.createGTextField("", 30, 220, 380, 60, this, GlobalStyle.setTextFormatLeading(GlobalStyle._textFormat1, 5));
            loc1.wordWrap = true;
            loc1.multiline = true;
            loc1.htmlText = Language.getString(28629);
            pushUIToDisposeVec(loc1);
            this._flyFootBmp = new FlyFootBmp();
            ObjCreate.setObjAttri(this._flyFootBmp, 300, 390, -1, -1, this);
            this._flyFootBmp.addEventListener(flash.events.MouseEvent.CLICK, this.onClickSendBtnHandler);
            var loc2=ObjCreate.createGTextField(Language.getString(28574), 248, 389, 52, 20, this, GlobalStyle.textFormatWhite, true);
            loc2.configEventListener(flash.events.TextEvent.LINK, this.onClickGotoBtnHandler);
            pushUIToDisposeVec(loc2);
            this._money = ObjCreate.createGTextField(Language.getStringByParam(28632, HTMLUtil.addColor(Cache.instance.role.money.spiritCoin.toString(), GlobalStyle.color2)), 120, 389, 130, 20, this, GlobalStyle._textFormat5, true);
            var loc3=ObjCreate.createGButton(Language.getString(28626), 115, 418, 62, 28, this);
            var loc4=ObjCreate.createGButton(Language.getString(28627), 240, 418, 62, 28, this);
            loc3.configEventListener(flash.events.MouseEvent.CLICK, this.onClickGotoBtnHandler);
            loc4.configEventListener(flash.events.MouseEvent.CLICK, this.onClickSendBtnHandler);
            if (!this._itemsSp) 
            {
                this._itemsSp = new Object /* flash.display.Sprite */();
                this._itemsSp.x = 40;
                this._itemsSp.y = 345;
                loc6 = 0;
                while (loc6 < 8) 
                {
                    loc5 = int("130" + loc6 + "4100");
                    (loc7 = new BgItem(loc5)).x = loc6 * 43;
                    this._itemsSp.addChild(loc7);
                    ++loc6;
                }
            }
            this.addChild(this._itemsSp);
            NetDispatcher.addCmdListener(ServerCommand.MoneyUpdate, this.onMoneyUpdateHandler);
            LoaderHelp.addResCallBack(ResFileConst.AttachedSoulBattlefield, this.onLoadResHandler);
            return;
        }

        protected /* override */ disposeImpl(arg1: Boolean=true): void
        {
            super.disposeImpl(arg1);
            this._money.dispose(arg1);
            this._flyFootBmp.dispose();
            DisplayUtil.removeMe(this._flyFootBmp);
            NetDispatcher.removeCmdListener(ServerCommand.MoneyUpdate, this.onMoneyUpdateHandler);
            return;
        }

        /* internal */ /* var */_flyFootBmp: FlyFootBmp;

        /* internal */ /* var */_npcTarget: TaskTargetInfo;

        /* internal */ /* var */_money: GTextFiled;

        /* internal */ /* var */_itemsSp: Object /* flash.display.Sprite */;
    }
